package xdu.lz.stage7_jucCollection.concurrentLinkedQueue;

import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * Created at 2019/10/30 0030 上午 10:36
 * --
 */
public class ConcurrentLinkedQueue1 {

    public static void main(String[] args) {
        test1(new LinkedList<>());
        test1(new ConcurrentLinkedQueue<>());
    }

    public static void test1(Queue<Integer> queue){
        System.out.println("queue = " + queue.getClass());
        long time1 = System.nanoTime();
        for (int i = 0; i < 10_0000; i++) {
            queue.offer(i);
        }
        while (!queue.isEmpty()){
            queue.poll();
        }
        long time2 = System.nanoTime();
        for (int i = 0; i < 10_0000; i++) {
            queue.offer(i);
        }
        while (queue.size() >0){
            queue.poll();
        }
        long time3 = System.nanoTime();
        System.out.println("isEmpty:"+(time2 - time1)/1000_000);
        System.out.println("size:"+(time3 - time2)/1000_000);
    }
}
